#include<iostream>
#include<string.h>
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

class Solution {
public:
    bool checkInclusion(string s1, string s2) {
        unordered_map<char, int>window, need;
        for (char c : s1) {
            need[c]++;
        }
        int l = 0, r = 0, ok = 0;
        while (r < s2.size()) {
            char c = s2[r];
            r++;
            if (need.count(c)) {
                window[c]++;
                if (window[c] == need[c]) {
                    ok++;
                }
            }
            while (r - l >= s1.size()) {
                cout << "wind:";
                for (const auto& n : window) {
                    cout << n.first << ":" << n.second << "  ";
                }
                cout << endl;
                cout << "need:";
                for (const auto& m : need) {
                    cout << m.first << ":" << m.second << "  ";
                }
                cout << endl;
                cout << "ok = " << ok << "  " << "need = " << need.size();
                cout << endl;
                if (ok == need.size()) {
                    return true;
                }
                char d = s2[l];
                l++;
                if (need.count(d)) {
                    if (window[d] == need[d]) {
                        ok--;
                    }
                    window[d]--;
                }
            }
        }
        
        
        return false;
    }
};
int main() {
    Solution awa;
    string s1, s2;
    freopen("q.txt", "r", stdin);
    cin >> s1;
    cin >> s2;
    if (awa.checkInclusion(s1, s2))
        cout << "ˬ";
    return 0;
}